//
//  HttpInterfaceManage.m
//  HuiKaoClient
//
//  Created by 龚 杰 on 13-3-4.
//  Copyright (c) 2013年 龚 杰. All rights reserved.
//

#import "HttpInterfaceManager.h"
#import "ASIFormDataRequest.h"
#import "CJSONDeserializer.h"
#import "AppDelegate.h"

static HttpInterfaceManager *sharedHttpInterfaceManager = nil;

@implementation HttpInterfaceManager
@synthesize delegate;



+ (HttpInterfaceManager*)sharedManager
{
    if (sharedHttpInterfaceManager == nil)
    {
        @synchronized(self)
        {
            sharedHttpInterfaceManager = [[super allocWithZone:NULL] init];
        }
        
    }
    return sharedHttpInterfaceManager;
}

+ (id)allocWithZone:(NSZone *)zone
{
    return [[self sharedManager] retain];
}

- (id)copyWithZone:(NSZone *)zone
{
    return self;
}

- (id)retain
{
    return self;
}

- (NSUInteger)retainCount
{
    return NSUIntegerMax;  //denotes an object that cannot be released
}

- (oneway void)release
{
    //do nothing
}

- (id)autorelease
{
    return self;
}

-(void)dealloc
{

    [super dealloc];
}

- (id)init
{
    if (self = [super init])
    {
        
    }
    return self;
}

#pragma mark Interface
#pragma mark 登陆
- (void)LoginRequestGet:(NSString*)username code:(NSString*)password
{
    NSString* url = [NSString stringWithFormat:@"%@ac=login&username=%@&password=%@",RequestCurrentURL,username,password];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(LoginFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)LoginRequestPost:(NSString*)username code:(NSString*)password
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=login",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:username forKey:@"username"];
    [tPostRequest setPostValue:password forKey:@"password"];
    [tPostRequest setDidFinishSelector:@selector(LoginFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)LoginFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        if (delegate != nil) {
            [delegate RequestResultsLogin:tDictionary];
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }

}
#pragma mark 注册
- (void)RegisterRequestGet:(NSString*)username email:(NSString*)_email code:(NSString*)password
{
    NSString* url = [NSString stringWithFormat:@"%@ac=register&username=%@&email=%@&password=%@",RequestCurrentURL,username,_email,password];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(RegisterFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)RegisterRequestPost:(NSString*)username email:(NSString*)_email code:(NSString*)password
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=login",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:username forKey:@"username"];
    [tPostRequest setPostValue:_email forKey:@"email"];
    [tPostRequest setPostValue:password forKey:@"password"];
    [tPostRequest setDidFinishSelector:@selector(LoginFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)RegisterFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        if (delegate !=nil) {
            [delegate RequestResultsRegister:tDictionary];
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }

}
#pragma mark 获得个人信息
- (void)GetUserinformationRequestGet:(NSString*)user_id
{
    
    NSString* url = [NSString stringWithFormat:@"%@ac=getUserInfo&user_id=%@",RequestCurrentURL,user_id];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetUserinformationFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetUserinformationPost:(NSString*)user_id
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=getUserInfo",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:user_id forKey:@"user_id"];
    [tPostRequest setDidFinishSelector:@selector(GetUserinformationFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)GetUserinformationFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        if (delegate !=nil) {
            [delegate RequestResultsGUI:tDictionary];
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark 获得报名查分列表
- (void)GetGOSURequestGet
{
    NSString* url = [NSString stringWithFormat:@"%@ac=getSignupInfo",RequestCurrentURL];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetGOSUFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetGOSUFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsGetGOSU:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark 获得考试提示
- (void)GetExReRequestGet:(NSString*)userid
{
    NSString* url = [NSString stringWithFormat:@"%@ac=getRemindList&cur_user_id=%@",RequestCurrentURL,userid];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetExReFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetExReFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsGetExRe:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }    }
}
#pragma mark 添加考试提示
- (void)AddExReRequestGet:(NSString*)userid province_ids:(NSString*)pids
{
    NSString* url = [NSString stringWithFormat:@"%@ac=setRemind&cur_user_id=%@&province_ids=%@",RequestCurrentURL,userid,pids];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AddExReFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)AddExReRequestPost:(NSString*)userid province_ids:(NSString*)pids
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=setRemind",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:userid forKey:@"user_id"];
    [tPostRequest setPostValue:pids forKey:@"province_ids"];
    [tPostRequest setDidFinishSelector:@selector(AddExReFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)AddExReFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsAddExRe:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark 获得省份列表
- (void)ProvincesListRequestGet
{
    NSString* url = [NSString stringWithFormat:@"%@ac=getProvinceList",RequestCurrentURL];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(ProvincesListFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)ProvincesListFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsProvincesList:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark 获得我的订单list
- (void)GetMyOrderListRequestGet:(NSString*)cur_user_id  page:(NSString*)_page pageSize:(NSString*)_pageSize
{
    NSString* url = [NSString stringWithFormat:@"%@ac=getUserOrderList&cur_user_id=%@&page=%@&pageSize=%@",RequestCurrentURL,cur_user_id,_page,_pageSize];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetMyOrderListFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetMyOrderListRequestPost:(NSString*)cur_user_id  page:(NSString*)_page pageSize:(NSString*)_pageSize
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=getUserOrderList",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:cur_user_id forKey:@"cur_user_id"];
    [tPostRequest setPostValue:_page forKey:@"page"];
    [tPostRequest setPostValue:_pageSize forKey:@"pageSize"];
    [tPostRequest setDidFinishSelector:@selector(GetMyOrderListFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)GetMyOrderListFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsGetMyOrder:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark  获得我的培训班list
- (void)GetMyTRCListRequestGet:(NSString*)cur_user_id  page:(NSString*)_page pageSize:(NSString*)_pageSize
{
    NSString* url = [NSString stringWithFormat:@"%@ac=getMyClasses&cur_user_id=%@&page=%@&pageSize=%@",RequestCurrentURL,cur_user_id,_page,_pageSize];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetMyTRCListFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetMyTRCListRequestPost:(NSString*)cur_user_id  page:(NSString*)_page pageSize:(NSString*)_pageSize
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=getMyClasses",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:cur_user_id forKey:@"cur_user_id"];
    [tPostRequest setPostValue:_page forKey:@"page"];
    [tPostRequest setPostValue:_pageSize forKey:@"pageSize"];
    [tPostRequest setDidFinishSelector:@selector(GetMyTRCListFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)GetMyTRCListFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsGetTRC:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark  获得我的收藏list
- (void)GetMyFavListRequestGet:(NSString*)cur_user_id  target:(NSString*)_target
                          page:(NSString*)_page pageSize:(NSString*)_pageSize

{
    NSString* url = [NSString stringWithFormat:@"%@ac=getMyFav&cur_user_id=%@&target=%@&page=%@&pageSize=%@",RequestCurrentURL,cur_user_id,_target,_page,_pageSize];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetMyFavListFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetMyFavListRequestPost:(NSString*)cur_user_id target:(NSString*)_target
                           page:(NSString*)_page pageSize:(NSString*)_pageSize
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=getMyFav",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:cur_user_id forKey:@"cur_user_id"];
    [tPostRequest setPostValue:_target forKey:@"target"];
    [tPostRequest setPostValue:_page forKey:@"page"];
    [tPostRequest setPostValue:_pageSize forKey:@"pageSize"];
    [tPostRequest setDidFinishSelector:@selector(GetMyFavListFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)GetMyFavListFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"errorCode"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsGetMyFav:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark 获得搜索订单
- (void)OrderSearchRequestGet:(NSString*)keyword
{
    NSString* url = [NSString stringWithFormat:@"%@ac=orderSearch&keyword=%@",RequestCurrentURL,keyword];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(OrderSearchFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)OrderSearchRequestPost:(NSString*)keyword
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=orderSearch",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:keyword forKey:@"keyword"];
    [tPostRequest setDidFinishSelector:@selector(OrderSearchFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)OrderSearchFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsOrderSearch:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark 获得搜索培训班
- (void)ClassesSearchRequestGet:(NSString*)keyword
{
    NSString* url = [NSString stringWithFormat:@"%@ac=classesSearch&keyword=%@",RequestCurrentURL,keyword];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(ClassesSearchFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)ClassesSearchRequestPost:(NSString*)keyword
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=classesSearch",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:keyword forKey:@"keyword"];
    [tPostRequest setDidFinishSelector:@selector(ClassesSearchFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)ClassesSearchFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsClassesSearch:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark 修改个人信息
- (void)ModifyMyDataRequestGet:(NSString*)_user_id private_code:(NSString*)_private_code
                      username:(NSString*)_username email:(NSString*)_email 
                  old_password:(NSString*)_old_password password:(NSString*)_password
{
    NSString* url = [NSString stringWithFormat:@"%@ac=modify&user_id=%@&private_code=%@&username=%@&email=%@&old_password=%@&password=%@",RequestCurrentURL,_user_id,_private_code,_username,_email,_old_password,_password];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(ModifyMyDataFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)ModifyMyDataRequestPost:(NSString*)_user_id private_code:(NSString*)_private_code
                       username:(NSString*)_username email:(NSString*)_email mobile:(NSString*)_mobile
                   old_password:(NSString*)_old_password password:(NSString*)_password
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=modify",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_user_id forKey:@"user_id"];
    [tPostRequest setPostValue:_private_code forKey:@"private_code"];
    [tPostRequest setPostValue:_username forKey:@"username"];
    [tPostRequest setPostValue:_email forKey:@"email"];
    [tPostRequest setPostValue:_old_password forKey:@"old_password"];
    [tPostRequest setPostValue:_password forKey:@"password"];
    [tPostRequest setDidFinishSelector:@selector(ModifyMyDataFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)ModifyMyDataFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsModifyMyData:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }

}


#pragma mark 咨询列表
- (void)GetConsultingLsitRequestGet:(NSString*)_userid UDID:(NSString*)_udid
                               page:(NSString*)_page pagenum:(NSString*)_pagenum
{
    NSString* url = [NSString stringWithFormat:@"%@ac=getAskList&cur_user_id=%@&UDID=%@&page=%@&pageSize=%@",RequestCurrentURL,_userid,_udid,_page,_pagenum];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetConsultingLsitFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)GetConsultingLsitRequestPost:(NSString*)_userid UDID:(NSString*)_udid
                                page:(NSString*)_page pagenum:(NSString*)_pagenum
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=getAskList",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_userid forKey:@"cur_user_id"];
    [tPostRequest setPostValue:_udid forKey:@"UDID"];
    [tPostRequest setPostValue:_page forKey:@"page"];
    [tPostRequest setPostValue:_pagenum forKey:@"pageSize"];
    [tPostRequest setDidFinishSelector:@selector(GetConsultingLsitFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)GetConsultingLsitFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSArray* data = [[tDictionary objectForKey:@"data"] objectForKey:@"list"];
            if (delegate != nil) {
                [delegate RequestResultsGetConsultingList:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark 发送咨询
- (void)SendConsultingRequestGet:(NSString*)_userid UDID:(NSString*)_udid message:(NSString*)_message
{
    NSString* url = [NSString stringWithFormat:@"%@ac=ask&cur_user_id=%@&UDID=%@&message=%@",RequestCurrentURL,_userid,_udid,_message];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(GetConsultingLsitFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)SendConsultingRequestPost:(NSString*)_userid UDID:(NSString*)_udid message:(NSString*)_message
{
    ASIFormDataRequest* tPostRequest =[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@ac=ask",RequestCurrentURL]]];
    [tPostRequest setDelegate:self];
    [tPostRequest setPostValue:_userid forKey:@"cur_user_id"];
    [tPostRequest setPostValue:_udid forKey:@"UDID"];
    [tPostRequest setPostValue:_message forKey:@"message"];
    [tPostRequest setDidFinishSelector:@selector(SendConsultingFinish:)];
    [tPostRequest startAsynchronous];
}
- (void)SendConsultingFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsSendConsulting:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark 第三方授权
- (void)AuthorizationRequestGet:(NSString*)target
{
    NSString* url = [NSString stringWithFormat:@"%@ac=oauthAuthorize&app=ihuikao&target=%@",RequestCurrentURL,target];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(AuthorizationsFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)AuthorizationsFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsAuthorizations:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark 第三方登陆
- (void)ThirdPartyLoginRequestGet:(NSString*)target token:(NSString*)_token
{
    NSString* url = [NSString stringWithFormat:@"%@ac=unionLogin&app=ihuikao&target=%@&token=%@",RequestCurrentURL,target,_token];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(ThirdPartyLoginFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)ThirdPartyLoginFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsThirdPartyLogin:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}

#pragma mark 忘记密码
- (void)ForgotPasswordRequestGet:(NSString*)EMail
{
    NSString* url = [NSString stringWithFormat:@"%@ac=resetpwd&email=%@",RequestCurrentURL,EMail];
    NSLog(@"url = %@",url);
	ASIHTTPRequest* tGetRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
    //    [tGetRequest setTimeOutSeconds:20.f];
	[tGetRequest setDelegate:self];
	[tGetRequest setDidFinishSelector:@selector(ForgotPasswordFinish:)];
    [tGetRequest startAsynchronous];
}
- (void)ForgotPasswordFinish:(ASIHTTPRequest*)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"%@",tStrReq);
    if ([tStrReq length] > 0) {
        NSError* tError;
        NSData *jsonData = [tStrReq dataUsingEncoding:NSUTF32BigEndianStringEncoding];
        NSDictionary *tDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&tError];
        int tErrorCode= [[tDictionary objectForKey:@"error_code"] intValue];
        if (tErrorCode == 0) {
            NSDictionary* data = [tDictionary objectForKey:@"data"];
            if (delegate != nil) {
                [delegate RequestResultsForgotPassword:data];
            }
        }else{
            if (delegate != nil) {
                [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:[tDictionary objectForKey:@"error_msg"]
                                                                          forKey:@"error_msg"] ];
            }
        }
    }else{
        if (delegate != nil) {
            [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
        }
    }
}
#pragma mark ASIHTTPRequestDelegate
- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSString* tStrReq =[request responseString];
    NSLog(@"err%@",tStrReq);
    if (delegate != nil) {
        [delegate RequestResultsErrer:[NSDictionary dictionaryWithObject:@"获得数据错误" forKey:@"error_msg"]];
    }
}

@end
